package sadi.client;


import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.util.*;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;

import sadi.client.WikiItem;

import com.jidesoft.swing.*;

/*
 * This class is just for testing ContentPanel
 */
public class GUI extends JFrame
{
	/*****************************************************************
	 * INTERFACE RELATED VARIABLES
	 *****************************************************************/
	/*********Main JPanel Wrappers**********/
	private JPanel pnlHeader;
	private JPanel pnlLeft;
	private JPanel pnlCenter;
	
	/*********Sub-Panels**************/
	private JPanel pnlWelcome;
	private JPanel pnlUser;
	private JPanel pnlSearch;
	private JPanel pnlLinks;
	private JPanel pnlChat;
	private JPanel pnlChatButton;
	private JPanel pnlChatArea;
	private JPanel pnlHighlight;
	private JPanel pnlWiki;
	private JPanel pnlFunc;
	
	/*************JLabel**************/
	private JLabel jlbWelcomeMsg;
	private JLabel jlbUsername;
	private JLabel jlbTitle;
	private JLabel jlbDesc;
	
	/*************JButton*************/
	private JButton jbtLogin;
	private JButton jbtRegister;
	private JButton jbtLogout;
	private JButton jbtSearch;
	private JButton jbtAddWiki;
	private JButton jbtApproveWiki;
	private JButton jbtReportedWiki;
	private JButton jbtUpdateWelcome;
	private JButton jbtChat;
	private JButton jbtEdit;
	private JButton jbtReport;
	private JButton jbtDelete;
	private JButton jbtDone;
	private JButton jbtClear;
	private JButton jbtApprove;
	private JButton jbtApproveAll;
	private JButton jbtDeny;
	private JButton jbtDeleteAll;
	private JButton jbtIgnore;
	
	/*************JTextFields*************/
	private JTextField jtfSearch;
	private JTextField jtfChat;
	private JTextField jtfTitle;
	private JTextField jtfDesc;
	
	/*************JTextArea************/
	private JTextArea jtaChatHistory;
	private JTextArea jtaContent;
	
	/*************JScrollPane*************/
	private JScrollPane jsp = null;
	private SimpleScrollPane ssp = null;
	
	/*********Layout Manager Variables*********/
	private GridBagConstraints gbc;
	private GridLayout grid = new GridLayout(2, 1, 5, 0);//For text in WikiItems
	
	/*********Other Interface Related Variables************/
	private TitledBorder tb;
	private Dimension sizeHL = new Dimension(400,40);//Dimension for Highlight Items
	
	/*****************************************************************
	 * FUNCTIONAL RELATED VARIABLES
	 *****************************************************************/
	/**********Storage for welcome message***********/
	private String welcomeMsg;
	
	/*********Storages for Wikis************/
	private Vector <WikiItem> vtHighlights = new Vector<WikiItem>();
	private Vector <WikiItem> vtWikis = new Vector<WikiItem>();
	private Vector <WikiItem> vtApprove = new Vector<WikiItem>();
	private Vector <WikiItem> vtReported = new Vector<WikiItem>();
 	private WikiItem wiki;
 	/*private Vector <ListItem> vtListItems;
 	private ListItem listItem;*/
 	private int currWikiID, currAuthor ;
 	private String currTitle, currDesc, currContent ;
 	
	
 	/*********Storages for User************/
 	private String username="";
	private int userID;
	private boolean isLogin;
	private boolean isAdmin;
	
	private int UserLevel = ADMIN;
	private static final int ADMIN = 0;
	private static final int USER  = 1;
	private static final int GUEST = 2;
	
	private int ContentType = VIEW;
	public static final int LIST_VIEW = 0;
	public static final int VIEW = 1;
	public static final int EDIT = 2;
	public static final int NEW = 3;
	public static final int LIST_APPROVE = 4;
	private static final int APPROVE = 5;
	public static final int LIST_REPORTED = 6;
	private static final int REPORTED = 7;
	
	/*******Others useful variables*******/
	int x, y;
	
	/***********FOR DEVELOPERS USE ONLY*******************/
	ArrayList<ArrayList> array;
	
	/*****************************************************************
	 * MVC RELATED VARIABLES
	 *****************************************************************/
	private WikiClient model;
	private Controller controller;

	private RegisterClient register;
	
	/*****************************************************************
	 * CONSTRUCTOR
	 *****************************************************************/
	public GUI()
	{		
		
		
		//-----------------Set the Layout Manager for JFrame----------------
		this.setLayout(new GridBagLayout());
		gbc = new GridBagConstraints();
		setUpGBC();
		
		//-------------initialises all the Functional and GUI components----------------
		/*****************************************************************
		 * FUNCTIONAL RELATED VARIABLES
		 *****************************************************************/
		/*********Storages for Wikis************/
		vtHighlights = new Vector<WikiItem>();
		vtWikis = new Vector<WikiItem>();
		vtApprove = new Vector<WikiItem>();
		vtReported = new Vector<WikiItem>();
	 	//vtListItems = new Vector<ListItem> ();
	    welcomeMsg /*Get the welcome msg at startup*/ = "";
		
	 	/*********Storages for User************/
		isLogin = false;
		isAdmin = false;
		UserLevel = GUEST;
		ContentType = LIST_VIEW;

		/*username = "Stanley";//testing
		userID = 123;//testing
		currAuthor = 123;//testing
		currWikiID = 1;*/
		
		/*****************************************************************
		 * INTERFACE RELATED VARIABLES
		 *****************************************************************/
		/*********Main JPanel Wrappers**********/
		pnlHeader = new JPanel(new BorderLayout());
		pnlLeft   = new JPanel(new GridBagLayout());
		pnlCenter = new JPanel(new BorderLayout());
		
		/*********Sub-Panels**************/
		pnlWelcome      = new JPanel();
		pnlUser         = new JPanel();
		pnlSearch       = new JPanel(new GridBagLayout());
		pnlLinks        = new JPanel(new GridBagLayout());
		pnlChat         = new JPanel(new BorderLayout());
		pnlChatButton   = new JPanel(new BorderLayout());
		pnlChatArea     = new JPanel(new BorderLayout());
		pnlHighlight    = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
		pnlWiki         = new JPanel(new GridBagLayout());
		pnlFunc         = new JPanel(new FlowLayout(FlowLayout.LEFT, 5 , 0));
		
		/*************JLabel**************/
		jlbWelcomeMsg = new JLabel(welcomeMsg);
		jlbUsername   = new JLabel(username);
		jlbTitle = new JLabel("Title: ");
		jlbDesc = new JLabel("Description: ");
		
		/*************JButton*************/
		jbtRegister          = new JButton("Register");
		jbtLogin             = new JButton("Login");
		jbtLogout            = new JButton("Logout");
		jbtSearch            = new JButton("                    Search                    ");
		jbtAddWiki           = new JButton("Add a Wiki");
		jbtApproveWiki       = new JButton("Approve Wiki");
		jbtReportedWiki      = new JButton("Reported Wiki");
		jbtUpdateWelcome     = new JButton("Update Welcome Message");
		jbtChat              = new JButton("Send");
		jbtEdit              = new JButton("Edit");
		jbtReport            = new JButton("Report Abuse");
		jbtDelete            = new JButton("Delete");
		jbtDone              = new JButton("Done");
		jbtClear             = new JButton("Clear");
		jbtApprove           = new JButton("Approve");
		jbtApproveAll        = new JButton("Approve All");
		jbtDeny              = new JButton("Deny");
		jbtDeleteAll         = new JButton("Delete All");
		jbtIgnore            = new JButton("Ignore");

		/*************JTextFields*************/
		jtfSearch = new JTextField();
		jtfChat   = new JTextField();
		jtfTitle  = new JTextField();
		jtfDesc   = new JTextField();
		
		/*********JScrollPane*********/
		//jsp = new JScrollPane(new JPanel());
		
		/*************JTextArea************/
		jtaChatHistory = new JTextArea();
		jtaContent     = new JTextArea();
		
		/*********Layout Manager Variables*********/
		gbc = new GridBagConstraints();
		
		//----------------- 2. layout all the GUI components------------------------

		/*****************************************************************
		 * Construct the pnlHeader
		 *****************************************************************/
		this.setWelcomeMsg("Welcome to Shared Wiki!");
		this.setUserPanel();
		this.constructHeader();
		
		
		/*****************************************************************
		 * Construct the pnlLeft
		 *****************************************************************/
		//pnlSearch - appears for every kind of user
		this.addCompWeight(pnlSearch, jtfSearch, gbc, GridBagConstraints.HORIZONTAL, 0, 0, 1, 1, 1.0, 0.0);
		this.addCompWeight(pnlSearch, jbtSearch, gbc, GridBagConstraints.HORIZONTAL, 0, 1, 1, 1, 1.0, 0.0);
		
		//pnlLinks
		setQuickLinks();
		
		//pnlChat
		//setChatPanel();
		
		/*****************************************************************
		 * Construct the pnlCenter
		 *****************************************************************/
		//pnlHighlight
		
		
		//setting up the SimpleScrollPane for pnlHighlight
		ssp = new SimpleScrollPane(pnlHighlight);
		ssp.setHorizontalUnitIncrement(35);
		ssp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
		ssp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		
		//pnlWiki
		
		/*****************************************************************
		 * Construct the main panels
		 *****************************************************************/
		//Create TitledBorders for all the sub-panels
		createTitledPanels(tb, "Search", pnlSearch, TitledBorder.CENTER ,TitledBorder.DEFAULT_POSITION, BorderFactory.createLineBorder(Color.black) );
	
		if (UserLevel == ADMIN || UserLevel == USER)
		{
			createTitledPanels(tb, "Quick Links", pnlLinks, TitledBorder.CENTER ,TitledBorder.DEFAULT_POSITION, BorderFactory.createLineBorder(Color.black));
			createTitledPanels(tb, "Live! Chat", pnlChat, TitledBorder.CENTER ,TitledBorder.DEFAULT_POSITION, BorderFactory.createLineBorder(Color.black));
			createTitledPanels(tb, "Today's Highlights", pnlHighlight, TitledBorder.LEFT ,TitledBorder.DEFAULT_POSITION, BorderFactory.createEmptyBorder());
		}
		
		//add all the sub-panels to pnlLeft
		this.addCompFill(pnlLeft, pnlSearch, gbc,GridBagConstraints.HORIZONTAL, 0, 0, 1, 1);
		this.addCompFill(pnlLeft, pnlLinks, gbc,GridBagConstraints.HORIZONTAL, 0, 1, 1, 1);
		if (UserLevel == ADMIN || UserLevel == USER)
			this.addCompWeight(pnlLeft, pnlChat, gbc,GridBagConstraints.BOTH, 0, 2, 1, 1, 1.0, 1.0);
		else//If User is not login, just add an empty JPanel
			this.addCompWeight(pnlLeft, new JPanel(), gbc,GridBagConstraints.BOTH, 0, 2, 1, 1, 1.0, 1.0);
		
		//add all the sub-panels to pnlCenter
		pnlCenter.add(ssp,BorderLayout.NORTH);
		pnlCenter.add(pnlWiki, BorderLayout.CENTER);
		pnlCenter.add(pnlFunc, BorderLayout.SOUTH);
		
		//Add the JPanels into JFrame using GridBagLayout
		this.addCompFill(this, pnlHeader, gbc, GridBagConstraints.BOTH, 0, 0, 2, 1);
		this.addCompFill(this, pnlLeft, gbc, GridBagConstraints.VERTICAL, 0, 1, 1, 1);
		this.addCompWeight(this, pnlCenter, gbc, GridBagConstraints.BOTH, 1, 1, 1, 1, 0.6, 0.9);

		/*****************************************************************
		 * Define the JFrame properties
		 *****************************************************************/
		this.setTitle("Shared Wiki");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(1024,600);
		this.setResizable(true);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
		
		model = new WikiClient(this);
		controller = new Controller(model, this);
		
		//startup();
		setWelcomeMsg(model.getIntroduction());
		setHighlights(model.getHighlightList());
		
		
	}
	
	/*First time running comes here*/
	public void startup()
	{
		//setWelcomeMsg("Lalala");//testing
		//setHighlights(/*ArrayList array*/);//testing
		//this.setModeListView(/*ArrayList array*/);//testing, no display for first time startup
	}
	
	
	/****************************************************************************
	 * THE REFRESHERS METHODS
	 ****************************************************************************/
	/*
	 * Refresh the pnlWiki
	 */
	public void refreshContent()
	{
		pnlWiki.removeAll();
		pnlFunc.removeAll();
		
		pnlWiki.revalidate();
		pnlWiki.repaint();
		pnlFunc.revalidate();
		pnlFunc.repaint();
	}
	
	/*
	 * Set the Welcome Message
	 */
	public void setWelcomeMsg(String msg)
	{
		//remove anything before this
		pnlWelcome.removeAll();
		
		//add the new component into pnlWelcome
		jlbWelcomeMsg = new JLabel(msg);
		pnlWelcome.add(jlbWelcomeMsg);
		
		//refresh the panel
		pnlWelcome.revalidate();
		pnlWelcome.repaint();
	}
	
	/*
	 * Refreshes pnlUser if User login/logout
	 */
	public void setUserPanel()
	{
		//remove anything before this
		pnlUser.removeAll();
		
		//add components into pnlUser
		pnlUser.setAlignmentX(RIGHT_ALIGNMENT);
		if(isLogin)
		{
			jlbUsername = new JLabel(username);/******************************************************/
			pnlUser.add(jlbUsername);
			pnlUser.add(jbtLogout);
		}
		else
		{
			pnlUser.add(jbtRegister);
			pnlUser.add(jbtLogin);
		}
		
		//refresh pnlUser
		pnlUser.revalidate();
		pnlUser.repaint();
	}
	/*
	 * Refreshes pnlQuickLink if User login/logout
	 */
	public void setQuickLinks()
	{
		//remove anything before this
		pnlLinks.removeAll();
		
		//check UserLevel and add components into pnlLinks
		x = 0; y = 0;
		
		if (isLogin && isAdmin)
		{
			this.addCompWeight(pnlLinks, jbtAddWiki, gbc,GridBagConstraints.HORIZONTAL, x, y++, 1, 1, 1.0, 0.9);
			this.addCompWeight(pnlLinks, jbtApproveWiki, gbc,GridBagConstraints.HORIZONTAL, x, y++, 1, 1, 1.0, 0.9);
			this.addCompWeight(pnlLinks, jbtReportedWiki, gbc,GridBagConstraints.HORIZONTAL, x, y++, 1, 1, 1.0, 0.9);
			this.addCompWeight(pnlLinks, jbtUpdateWelcome, gbc,GridBagConstraints.HORIZONTAL, x, y++, 1, 1, 1.0, 0.9);
			//refresh the panel for quick links
			createTitledPanels(tb, "Quick Links", pnlLinks, TitledBorder.CENTER ,TitledBorder.DEFAULT_POSITION, BorderFactory.createLineBorder(Color.black));
			pnlLinks.revalidate();
			pnlLinks.repaint();
		}
		
		else if (isLogin && !isAdmin)
		{
			this.addCompWeight(pnlLinks, jbtAddWiki, gbc,GridBagConstraints.HORIZONTAL, x, y++, 1, 1, 1.0, 0.0);
			//refresh the panel for quick links
			createTitledPanels(tb, "Quick Links", pnlLinks, TitledBorder.CENTER ,TitledBorder.DEFAULT_POSITION, BorderFactory.createLineBorder(Color.black));
			pnlLinks.revalidate();
			pnlLinks.repaint();
		}
		else if (!isLogin)
		{
			//GUEST cannot do anything with the links
			pnlLinks = new JPanel(new GridBagLayout());
			createTitledPanels(tb, "", pnlLinks, TitledBorder.CENTER ,TitledBorder.DEFAULT_POSITION, BorderFactory.createEmptyBorder());
			pnlLinks.revalidate();
			pnlLinks.repaint();
		}
		else/**********************************************************/
		{
			pnlLinks.removeAll();
		}
		
		pnlLinks.revalidate();
		pnlLinks.repaint();
		
		pnlLeft.revalidate();
		pnlLeft.repaint();

	}
	
	/*
	 * Refreshes pnlChat if User login/logout
	 */
	/*public void setChatPanel()
	{
		//remove everything before this
		pnlChat.removeAll();
		
		//add components intno pnlChat
		if(isLogin)
		{
			jtaChatHistory.setEditable(false);
			JScrollPane jspChatHistory = new JScrollPane(jtaChatHistory); 
			jspChatHistory.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
			jspChatHistory.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			pnlChatButton.add(jbtChat, BorderLayout.EAST);
			
			pnlChatArea.add(jtfChat,BorderLayout.CENTER);
			pnlChatArea.add(pnlChatButton, BorderLayout.SOUTH);
			
			pnlChat.add(jspChatHistory, BorderLayout.CENTER);
			pnlChat.add(pnlChatArea,BorderLayout.SOUTH);
		}
		else if(!isLogin)
		{
			//GUEST cannot do anything with the chat room
		}
		
		//refresh the panel for chat
		pnlChat.revalidate();
		pnlChat.repaint();
	}*/
	/*
	 * Refreshes the Highlights
	 * Today's Highlights will be available everytime
	 */
	public void setHighlights(ArrayList<ArrayList<String>> param)
	{
		vtHighlights.removeAllElements();
		//remove anything before this
		pnlHighlight.removeAll();
		
		//Get information from database (ArrayList)
		//array = this.createArrayList();//testing purposes
		
		ListIterator li1 = param.listIterator();
		while (li1.hasNext())
		{
			ArrayList <String> str = (ArrayList<String>) li1.next();
			ListIterator li2 = str.listIterator();
			while(li2.hasNext())
			{
				int index = Integer.parseInt(li2.next().toString());
				this.createHighlightItem(index, li2.next().toString(), li2.next().toString());
			}
		}
		
		//display the items into the panel
		this.displayHighlights(vtHighlights, pnlHighlight);
		
		//refresh the panel highlight
		pnlHighlight.revalidate();
		pnlHighlight.repaint();
	}
	
	/*
	 * Refreshes the pnlWiki for different ContentType
	 */
	//0 = LIST_VIEW
	public void setModeListView(ArrayList <ArrayList<String>>array)
	{
		//remove anything from pnlWiki before this
		pnlWiki.removeAll();
		
		/**********Content Viewer**********/
		//Get information from database (ArrayList)
		//array = this.createArrayList();//testing purposes
		vtWikis.clear();
		
		ListIterator li1 = array.listIterator();
		while (li1.hasNext())
		{
			ArrayList <String> str = (ArrayList<String>) li1.next();
			ListIterator li2 = str.listIterator();
			while(li2.hasNext())
			{	
				int index = Integer.parseInt(li2.next().toString());
				this.createWikiItem(index, li2.next().toString(), li2.next().toString());
				//li2.next();//testing to throw out the author id
			}
		}
		
		//add components into pnlWiki
		JPanel temp = new JPanel(new GridBagLayout());
		this.displayWikiItems(vtWikis, temp);
		//System.out.println("vtWikiSize: " + vtWikis.size());
		//setting up the JScrollPane for pnlWiki
		jsp = new JScrollPane(temp);
		jsp.setWheelScrollingEnabled(true);
		jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		
		this.addCompWeight(pnlWiki, jsp, gbc, GridBagConstraints.BOTH, 0, 2, 2, 1, 1.0, 1.0);

		
		//refreshes pnlWiki
		pnlWiki.revalidate();
		pnlWiki.repaint();
		pnlFunc.removeAll();
		pnlFunc.revalidate();
		pnlFunc.repaint();
		
		ContentType = VIEW;
	}
	
	// 1 = VIEW
	public void setModeView(ArrayList<String> str, int type)/**************/
	{
		if(str.size() == 0)
			   return;

		/**********Content Viewer**********/
		//remove everything before this
		pnlWiki.removeAll();
		
		//Get information from database (ArrayList)
		//array = this.createArrayList();//testing purposes
		//ArrayList <String>str = array.get(0);//testing purposes
		
		ListIterator li = str.listIterator();
		currWikiID = Integer.parseInt(li.next().toString());
		currTitle = li.next().toString();
		currDesc = li.next().toString();
		currContent = li.next().toString();//this is the suppose to be condition
		//currContent = "blablabla\nYO!";//testing.. Delete this line after the array is available
		currAuthor = Integer.parseInt(li.next().toString());
		
		JLabel jlbViewTitle = new JLabel(currTitle);
		JLabel jlbViewDesc = new JLabel(currDesc);
		JTextArea jtaViewContent = new JTextArea();
			jtaViewContent.setEditable(false);
			jtaViewContent.setText(currContent);
		jsp = new JScrollPane(jtaViewContent);
			jsp.setWheelScrollingEnabled(true);
			jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
			jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		
		//Add components into panel
		this.addCompWeight(pnlWiki, jlbTitle, gbc,GridBagConstraints.HORIZONTAL, 0, 0, 1, 1, 0.0, 0.0);
		this.addCompWeight(pnlWiki, jlbDesc, gbc, GridBagConstraints.HORIZONTAL, 0, 1, 1, 1, 0.0, 0.0);
		this.addCompWeight(pnlWiki, jlbViewTitle, gbc, GridBagConstraints.HORIZONTAL, 1, 0, 1, 1, 1.0, 0.0);
		this.addCompWeight(pnlWiki, jlbViewDesc, gbc, GridBagConstraints.HORIZONTAL, 1, 1, 1, 1, 1.0, 0.0);
		this.addCompWeight(pnlWiki, jsp, gbc, GridBagConstraints.BOTH, 0, 2, 2, 1, 1.0, 1.0);
		
		/**********Functional Buttons**********/
		//remove everything from pnlFunc
		pnlFunc.removeAll();
		
		if(isLogin)/*********************************/
		{
			/*******View********/
			//if (type == VIEW)
			{
				pnlFunc.add(jbtEdit);
				pnlFunc.add(jbtReport);
				pnlFunc.add(jbtDelete);
				if (!(userID == currAuthor))
				{
					jbtEdit.setEnabled(false);
					jbtDelete.setEnabled(false);
				}
				else
				{
					jbtEdit.setEnabled(true);
					jbtDelete.setEnabled(true);
				}
			}
			
			/********Approve***********/
			if (type == LIST_APPROVE)
			{
				pnlFunc.removeAll();
				if(isAdmin)
				{
					pnlFunc.add(jbtApprove);
					pnlFunc.add(jbtDelete);
					jbtDelete.setEnabled(true);
				}
				ContentType = LIST_VIEW;
			}
			
			/********Delete***********/
			else if (type == LIST_REPORTED)
			{
				pnlFunc.removeAll();
				if(isAdmin)
				{
					//pnlFunc.add(jbtApprove);
					pnlFunc.add(jbtDelete);
					//pnlFunc.add(jbtIgnore);
				}
				ContentType = LIST_VIEW;
			}
		}
		
		//refresh pnlFunc
		pnlWiki.revalidate();
		pnlWiki.repaint();
		pnlFunc.revalidate();
		pnlFunc.repaint();
		
		pnlCenter.revalidate();
		pnlCenter.repaint();
		
		ContentType = VIEW;
	}
	
	//2=EDIT
	public void setModeEdit()
	{
		
		if (isLogin && userID == currAuthor )
		{
			/**********Content Editor**********/
			//remove everything from pnlWiki
			pnlWiki.removeAll();
			
			
			jtfTitle.setText(currTitle);
			jtfDesc.setText(currDesc);
			jtaContent = new JTextArea();
			jtaContent.setText(currContent);
			jsp = new JScrollPane(jtaContent);
				jsp.setWheelScrollingEnabled(true);
				jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
				jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			
				//Add components into panel
			this.addCompWeight(pnlWiki, jlbTitle, gbc,GridBagConstraints.HORIZONTAL, 0, 0, 1, 1, 0.0, 0.0);
			this.addCompWeight(pnlWiki, jlbDesc, gbc, GridBagConstraints.HORIZONTAL, 0, 1, 1, 1, 0.0, 0.0);
			this.addCompWeight(pnlWiki, jtfTitle, gbc, GridBagConstraints.HORIZONTAL, 1, 0, 1, 1, 1.0, 0.0);
			this.addCompWeight(pnlWiki, jtfDesc, gbc, GridBagConstraints.HORIZONTAL, 1, 1, 1, 1, 1.0, 0.0);
			this.addCompWeight(pnlWiki, jsp, gbc, GridBagConstraints.BOTH, 0, 2, 2, 1, 1.0, 1.0);
			
			/**********Functional Buttons**********/
			//remove everything before this
			pnlFunc.removeAll();
			
			//add new buttons into panel function
			pnlFunc.add(jbtDone);
			pnlFunc.add(jbtClear);
			
			//refreshes the pnl
			pnlWiki.revalidate();
			pnlWiki.repaint();
			pnlFunc.revalidate();
			pnlFunc.repaint();
			
			ContentType = EDIT;
		}
	}
	
	//3=NEW
	public void setModeNew()
	{
		if(isLogin)
		{
			/**********Content Editor**********/
			//remove everything before this
			pnlWiki.removeAll();
			
			JScrollPane jspNewContent = new JScrollPane(jtaContent);
				jspNewContent.setWheelScrollingEnabled(true);
				jspNewContent.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
				jspNewContent.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

			this.addCompWeight(pnlWiki, jlbTitle, gbc,GridBagConstraints.HORIZONTAL, 0, 0, 1, 1, 0.0, 0.0);
			this.addCompWeight(pnlWiki, jlbDesc, gbc, GridBagConstraints.HORIZONTAL, 0, 1, 1, 1, 0.0, 0.0);
			this.addCompWeight(pnlWiki, jtfTitle, gbc, GridBagConstraints.HORIZONTAL, 1, 0, 1, 1, 1.0, 0.0);
			this.addCompWeight(pnlWiki, jtfDesc, gbc, GridBagConstraints.HORIZONTAL, 1, 1, 1, 1, 1.0, 0.0);
			this.addCompWeight(pnlWiki, jspNewContent, gbc, GridBagConstraints.BOTH, 0, 2, 2, 1, 1.0, 1.0);
			
			/**********Functional Buttons**********/
			//remove everything before this
			pnlFunc.removeAll();
			
			//add componenets into panel
			pnlFunc.add(jbtDone);
			pnlFunc.add(jbtClear);
			
			//refreshes the panels
			pnlWiki.revalidate();
			pnlWiki.repaint();
			pnlFunc.revalidate();
			pnlFunc.repaint();
			
			ContentType = NEW;
		}
	}
	
	//4=LIST_APPROVE
	public void setModeListApprove(ArrayList<ArrayList<String>> param)
	{
		if(param.size() == 0)
			   return;
		
		if (isLogin && isAdmin && UserLevel == ADMIN)
		{
			//remove pnlWiki
			pnlWiki.removeAll();
			
			vtApprove = new Vector<WikiItem>();
			
			//Get information from database (ArrayList)
			//array = this.createArrayList();//testing purposes
		
			ListIterator li1 = array.listIterator();
			while (li1.hasNext())
			{
				ArrayList <String> str = (ArrayList<String>) li1.next();
				ListIterator li2 = str.listIterator();
				while(li2.hasNext())
				{	
					int index = Integer.parseInt(li2.next().toString());
					String title = li2.next().toString();
					int author = Integer.parseInt(li2.next().toString());
					currAuthor = author;
					this.createWikiItem(index, title, "");
					//li2.next();//testing to throw out the author id
				}
			}
			
			//add components into pnlWiki
			JPanel temp = new JPanel(new GridBagLayout());
			this.displayWikiItems(vtApprove, temp);
			//System.out.println("vtWikiSize: " + vtWikis.size());
			//setting up the JScrollPane for pnlWiki
			jsp = new JScrollPane(temp);
			jsp.setWheelScrollingEnabled(true);
			jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
			jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			
			this.addCompWeight(pnlWiki, jsp, gbc, GridBagConstraints.BOTH, 0, 2, 2, 1, 1.0, 1.0);

			
			//refreshes pnlWiki
			pnlWiki.revalidate();
			pnlWiki.repaint();
			pnlFunc.removeAll();
			pnlFunc.revalidate();
			pnlFunc.repaint();
			
			ContentType = LIST_APPROVE;
		}
	}
	//5=APPROVE
	public void setModeApprove(/*ArrayList array*/)
	{
		if (isLogin && isAdmin && UserLevel == ADMIN)
		{
			//remove from pnlWiki
			pnlWiki.removeAll();
			
			/**********Content Viewer**********/
			//Get information from database (ArrayList)
			array = this.createArrayList();//testing purposes
			ArrayList <String>str = array.get(0);//testing purposes
			
			ListIterator li = str.listIterator();
			currWikiID = Integer.parseInt(li.next().toString());
			currTitle = li.next().toString();
			currDesc = li.next().toString();
			//currContent = li.next().toString();
			currContent = "blablabla\nYO!";//testing.. Delete this line after the array is available
			currAuthor = Integer.parseInt(li.next().toString());
			
			JLabel jlbViewTitle = new JLabel(currTitle);
			JLabel jlbViewDesc = new JLabel(currDesc);
			JTextArea jtaViewContent = new JTextArea();
				jtaViewContent.setEditable(false);
				jtaViewContent.setText(currContent);
			jsp = new JScrollPane(jtaViewContent);
				jsp.setWheelScrollingEnabled(true);
				jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
				jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
				
			//Add components into panel
			this.addCompWeight(pnlWiki, jlbTitle, gbc,GridBagConstraints.HORIZONTAL, 0, 0, 1, 1, 0.0, 0.0);
			this.addCompWeight(pnlWiki, jlbDesc, gbc, GridBagConstraints.HORIZONTAL, 0, 1, 1, 1, 0.0, 0.0);
			this.addCompWeight(pnlWiki, jlbViewTitle, gbc, GridBagConstraints.HORIZONTAL, 1, 0, 1, 1, 1.0, 0.0);
			this.addCompWeight(pnlWiki, jlbViewDesc, gbc, GridBagConstraints.HORIZONTAL, 1, 1, 1, 1, 1.0, 0.0);
			this.addCompWeight(pnlWiki, jsp, gbc, GridBagConstraints.BOTH, 0, 2, 2, 1, 1.0, 1.0);
			
			//remove from pnlFunc	
			pnlFunc.removeAll();
			
			//add components into pnlFunc
			pnlFunc.add(jbtApprove);
			pnlFunc.add(jbtDeny);
		}
		
		//refreshes the panels
		pnlWiki.revalidate();
		pnlWiki.repaint();
		pnlFunc.revalidate();
		pnlFunc.repaint();
		
		ContentType = APPROVE;
			
	}
	
	//6=LIST_REPORTED
	public void setModeListReported(ArrayList<ArrayList<String>> param)
	{
		//remove pnlWiki
		pnlWiki.removeAll();
		
		vtReported = new Vector<WikiItem>();
		
		//Get information from database (ArrayList)
		//array = this.createArrayList();//testing purposes
	
		ListIterator li1 = array.listIterator();
		while (li1.hasNext())
		{
			ArrayList <String> str = (ArrayList<String>) li1.next();
			ListIterator li2 = str.listIterator();
			while(li2.hasNext())
			{
				int index = Integer.parseInt(li2.next().toString());
				String title = li2.next().toString();
				int author = Integer.parseInt(li2.next().toString());
				currAuthor = author;
				this.createWikiItem(index, title, "");
				//li2.next();//testing to throw out the author id
			}
		}
		
		//add components into pnlWiki
		JPanel temp = new JPanel(new GridBagLayout());
		this.displayWikiItems(vtReported, temp);
		//System.out.println("vtWikiSize: " + vtWikis.size());
		//setting up the JScrollPane for pnlWiki
		jsp = new JScrollPane(temp);
		jsp.setWheelScrollingEnabled(true);
		jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		
		this.addCompWeight(pnlWiki, jsp, gbc, GridBagConstraints.BOTH, 0, 2, 2, 1, 1.0, 1.0);

		
		//refreshes pnlWiki
		pnlWiki.revalidate();
		pnlWiki.repaint();
		pnlFunc.removeAll();
		pnlFunc.revalidate();
		pnlFunc.repaint();
			
			ContentType = LIST_REPORTED;
	}
	
	
	
	//7=REPORTED
	public void setModeReported(/*ArrayList array*/)
	{
		if (isLogin && isAdmin && UserLevel == ADMIN)
		{
			/**********Content Viewer**********/
			//removes all from pnlWiki
			pnlWiki.removeAll();
			
			//Get information from database (ArrayList)
			array = this.createArrayList();//testing purposes
			ArrayList <String>str = array.get(0);//testing purposes
			
			ListIterator li = str.listIterator();
			currWikiID = Integer.parseInt(li.next().toString());
			currTitle = li.next().toString();
			currDesc = li.next().toString();
			//currContent = li.next().toString();
			currContent = "blablabla\nYO!";//testing.. Delete this line after the array is available
			currAuthor = Integer.parseInt(li.next().toString());
			
			JLabel jlbViewTitle = new JLabel(currTitle);
			JLabel jlbViewDesc = new JLabel(currDesc);
			JTextArea jtaViewContent = new JTextArea();
				jtaViewContent.setEditable(false);
				jtaViewContent.setText(currContent);
			jsp = new JScrollPane(jtaViewContent);
				jsp.setWheelScrollingEnabled(true);
				jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
				jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
				
			//Add components into panel
			this.addCompWeight(pnlWiki, jlbTitle, gbc,GridBagConstraints.HORIZONTAL, 0, 0, 1, 1, 0.0, 0.0);
			this.addCompWeight(pnlWiki, jlbDesc, gbc, GridBagConstraints.HORIZONTAL, 0, 1, 1, 1, 0.0, 0.0);
			this.addCompWeight(pnlWiki, jlbViewTitle, gbc, GridBagConstraints.HORIZONTAL, 1, 0, 1, 1, 1.0, 0.0);
			this.addCompWeight(pnlWiki, jlbViewDesc, gbc, GridBagConstraints.HORIZONTAL, 1, 1, 1, 1, 1.0, 0.0);
			this.addCompWeight(pnlWiki, jsp, gbc, GridBagConstraints.BOTH, 0, 2, 2, 1, 1.0, 1.0);
			
			//remove from pnlFunc
			pnlFunc.removeAll();
			
			//add components into pnlFunc
			pnlFunc.add(jbtDelete);
			pnlFunc.add(jbtIgnore);
		}
		
		//refreshes the panels
		pnlWiki.revalidate();
		pnlWiki.repaint();
		pnlFunc.revalidate();
		pnlFunc.repaint();
		
		ContentType = REPORTED;
			
	}
	/****************************************************************************
	 * SUB-CONSTRUCTOR METHODS
	 ****************************************************************************/
	/*
	 * Construct the header
	 */
	
	public void constructHeader()
	{
		//add the sub-panels to the main panel
		pnlHeader.add(pnlWelcome, BorderLayout.CENTER);
		pnlHeader.add(pnlUser,BorderLayout.EAST);
	}
	
		
	/*
	 * Today's Highlight Related methods
	 */
	private void createHighlightItem(int wikiID, String title, String description)
	{
		wiki = new WikiItem(wikiID);
		wiki.addActionListener(controller.getHighlightListener());
		
		JLabel lblTitle = new JLabel(title);
		JLabel lblDesc = new JLabel(description);
		
		wiki.setPreferredSize(sizeHL);
		wiki.setLayout(grid);
		wiki.add(lblTitle);
		wiki.add(lblDesc);
		
		vtHighlights.add(wiki);
	}
	
	private void displayHighlights(Vector <WikiItem> vector, JPanel pnl)
	{
		ListIterator<WikiItem> li = vector.listIterator();
		
		while (li.hasNext())
		{
			pnl.add(li.next());
		}
		
		pnl.revalidate();
		pnl.repaint();
	}
	
	/*
	 * Wiki's List Related methods
	 */
	private void createWikiItem(int wikiID, String title, String description)
	{
		wiki = new WikiItem(wikiID);
		wiki.addActionListener(controller.getHighlightListener());

		JLabel lblTitle = new JLabel(title);
		JLabel lblDesc = new JLabel(description);
		wiki.setLayout(grid);
		wiki.add(lblTitle);
		wiki.add(lblDesc);
		
		vtWikis.add(wiki);
	}
	
	public void displayWikiItems(Vector <WikiItem> vector, JPanel pnl)
	{
		ListIterator<WikiItem> li = vector.listIterator();
		int y = 0;
		while (li.hasNext())
		{
			WikiItem wi = li.next();
			this.addCompWeight(pnl, wi, gbc, GridBagConstraints.BOTH, 0, y++, 1, 1, 1.0, 0.0);
		}
		
		JPanel dummyPanel = new JPanel();
		this.addCompWeight(pnl, dummyPanel, gbc, GridBagConstraints.BOTH, 0, y, 1, 1, 1.0, 1.0);
		
		pnl.revalidate();
		pnl.repaint();
	}
	
	/*
	 * List Items related method
	 */
	/*private void createListItem(int wikiID, String title, String author, Vector<ListItem> vector)
	{
		listItem = new ListItem(wikiID, title, author);
		vector.add(listItem);
	}
	
	public void displayListItems(String header1, String header2, String header3, Vector <ListItem> vector, JPanel pnl)
	{
		JLabel jlbWiki = new JLabel (header1);
		JLabel jlbAuthor = new JLabel (header2);
		JLabel jlbSelect = new JLabel (header3);
		
		//Print the header
		this.addCompWeight(pnl, jlbWiki, gbc, GridBagConstraints.HORIZONTAL, 0, 0, 1, 1, 0.6, 0.0);
		this.addCompWeight(pnl, jlbAuthor, gbc, GridBagConstraints.HORIZONTAL, 1, 0, 1, 1, 0.3, 0.0);
		this.addCompWeight(pnl, jlbSelect, gbc, GridBagConstraints.HORIZONTAL, 2, 0, 1, 1, 0.1, 0.0);
		
		//print the contents
		ListIterator<ListItem> li = vector.listIterator();
		int y = 1;
		while (li.hasNext())
		{
			ListItem list = li.next();
			this.addCompWeight(pnl, list.getWikiItem(), gbc, GridBagConstraints.BOTH, 0, y, 1, 1, 0.6, 0.0);
			this.addCompWeight(pnl, list.getJLabelAuthor(), gbc, GridBagConstraints.BOTH, 1, y, 1, 1, 0.3, 0.0);
			this.addCompWeight(pnl, list.getCheckBox(), gbc, GridBagConstraints.BOTH, 2, y++, 1, 1, 0.1, 0.0);
		}
		
		JPanel dummyPanel = new JPanel();
		this.addCompWeight(pnl, dummyPanel, gbc, GridBagConstraints.BOTH, 0, y, 1, 1, 1.0, 1.0);
		pnl.revalidate();
		pnl.repaint();
	}*/
	/****************************************************************************
	 * GRIDBAGLAYOUT RELATED METHODS
	 ****************************************************************************/
	/*
	 * GridBagConstraints Properties
	 */
	
	
	private void setUpGBC()
	{
		gbc = new GridBagConstraints();
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.insets = new Insets(2,2,2,2);
		gbc.ipadx = 0;
		gbc.ipady = 0;
		gbc.weightx = 0;
		gbc.weighty = 0;
	}
	
	/*
	 * GridBagLayout Methods
	 */
	//adding component to the layout based on constraints
	private void addComp(Container parentCom, Component childCom, GridBagConstraints g, int x, int y, int numOfCol, int numOfRow)
	{
		g.gridx = x;
		g.gridy = y;
		g.gridwidth = numOfCol;
		g.gridheight = numOfRow;
		parentCom.add(childCom, g);
	}
  
	//this method allows to specify the constraint's FILL
	private void addCompFill(Container parentCom, Component childCom, GridBagConstraints g, int gbcFill, int x, int y, int numOfCol, int numOfRow)
	{
		int original_fill = g.fill;
		g.fill = gbcFill; 
		this.addComp(parentCom, childCom, g, x, y, numOfCol, numOfRow);
	
		g.fill = original_fill;
	}

	//this method allows to specify the constraint's WEIGHT
	private void addCompWeight(Container parentCom, Component childCom, GridBagConstraints g, int gbcFill, int x, int y, int numOfCol, int numOfRow, double weightX, double weightY)
	{
		int original_fill = g.fill;
		g.fill = gbcFill; 
		double original_WeightX = g.weightx;
		double original_WeightY = g.weighty;
		g.weightx = weightX;
		g.weighty = weightY;
		this.addComp(parentCom, childCom, g, x, y, numOfCol, numOfRow);
	
		g.weightx = original_WeightX;
		g.weighty = original_WeightY;
		g.fill = original_fill;
	}
	
	//this method allows to specify the constraint's ANCHOR
	private void addCompAnchor(Container parentCom, Component childCom, GridBagConstraints g, int gbcAnchor, int x, int y, int numOfCol, int numOfRow)
	{
		int original_anchor = g.anchor;
		
		g.anchor = gbcAnchor;
		this.addComp(parentCom, childCom, g, x, y, numOfCol, numOfRow);
		
		g.anchor = original_anchor;
	}
	
	/****************************************************************************
	 * LOOK & FEEL RELATED METHODS
	 ****************************************************************************/
	/*
	 * Method to create the titled borders
	 */
	private void createTitledPanels(TitledBorder tb, String title, JPanel pnl, int justify, int position, Border border)
	{
		tb = BorderFactory.createTitledBorder(title);
		tb.setTitleJustification(justify);
		tb.setTitlePosition(position);
		tb.setBorder(border);
		pnl.setBorder(tb);
	}
	
	/****************************************************************************
	 * THE PROMPTS AND POPUPS
	 ****************************************************************************/
	
	public int promptConfirm(String title, Object msg)
	{
		return JOptionPane.showConfirmDialog(null, msg, title, JOptionPane.YES_NO_OPTION);
	}
	
	public void promptMsg(String title, String msg, int msgType)
	{
		JOptionPane.showMessageDialog(null, msg, title, msgType);
	}
	
	public String promptInput()
	{
		String input = JOptionPane.showInputDialog(null, "Please enter the new Welcome Message");
		return input;
	}
	
	public void promptRegister(ActionListener newAct, ActionListener clearAct, ActionListener cancelAct)
	{
		register = new RegisterClient(this, "Register");
		register.addNewUserListener(newAct);
		register.addClearFormListener(clearAct);
		register.addCancelRegistrationListener(cancelAct);
	}
	
	/****************************************************************************
	 * THE GETTERS AND SETTERS
	 ****************************************************************************/
	public int getUserID(){return userID;}
	public int getUserLevel(){return UserLevel;}
	public int getContentType(){return ContentType;}
	public boolean getIsLogin(){return isLogin;}
	public boolean getIsAdmin(){return isAdmin;}
	public String getUsername(){return username;}
	public Vector<WikiItem> getHighLights(){return this.vtHighlights;}
	public Vector<WikiItem> getWikis(){return this.vtWikis;}
	public int getCurrWikiID(){return currWikiID;}
	public int getCurrAuthor(){return currAuthor;}
	public String getCurrContent(){return currContent;}
	public String getCurrDesc(){return currDesc;}
	public String getCurrTitle(){return currTitle;}
	
	/*Get User inputs*/
	public String getSearchKeyword(){return this.jtfSearch.getText();}
	public String getInputTitle(){return this.jtfTitle.getText();}
	public String getInputDesc(){return this.jtfDesc.getText();}
	public String getInputContent(){return this.jtaContent.getText();}
	
	/*Clear all the text fields*/
	public void clearTitle(){this.jtfTitle.setText("");}
	public void clearDesc(){this.jtfDesc.setText("");}
	public void clearContent(){this.jtaContent.setText("");}
	
	public void setUserID(int userID){this.userID = userID;}
	public void setUserLevel(int level){this.UserLevel = level;}
	public void setContentType(int type){this.ContentType = type;}
	public void setIsLogin(boolean bool){isLogin = bool;}
	public void setIsAdmin(boolean bool){isAdmin = bool;}
	public void setUsername(String username){this.username = username;}
	public void setCurrWikiID (int id){this.currWikiID = id;}
	public void setCurrAuthor(int autID){this.currAuthor = autID;}
	public void setCurrContent(String text){this.currContent = text;}
	public void setCurrDesc(String text){this.currDesc = text;}
	public void setCurrTitle(String text){this.currTitle = text;}
	
	/****************************************************************************
	 * PROGRAM ENTRY POINT
	 ****************************************************************************/
	public static void main(String[] args) throws IOException
	{
		new GUI();
	}
	
	/****************************************************************************
	* ACTION LISTENER SECTION:
	* All the add action listeners methods
	****************************************************************************/
	public void addRegisterListener(ActionListener lsn)
	{
		jbtRegister.addActionListener(lsn);
	}
	
	public void addLoginListener(ActionListener lsn)
	{
		jbtLogin.addActionListener(lsn);
	}
	
	public void addLogoutListener(ActionListener lsn)
	{
		jbtLogout.addActionListener(lsn);
	}
	
	public void addSearchListener(ActionListener lsn)
	{
		jbtSearch.addActionListener(lsn);
	}
	
	public void addAddWikiListener(ActionListener lsn)
	{
		jbtAddWiki.addActionListener(lsn);
	}
	
	public void addApproveWikiListener(ActionListener lsn)
	{
		jbtApproveWiki.addActionListener(lsn);
	}
	
	public void addReportedWikiListener(ActionListener lsn)
	{
		jbtReportedWiki.addActionListener(lsn);
	}
	
	public void addUpdateWelcomeListener(ActionListener lsn)
	{
		jbtUpdateWelcome.addActionListener(lsn);
	}
	
	public void addChatListener(ActionListener lsn)
	{
		jbtChat.addActionListener(lsn);
	}
	
	public void addEditListener(ActionListener lsn)
	{
		jbtEdit.addActionListener(lsn);
	}
	
	public void addReportListener(ActionListener lsn)
	{
		jbtReport.addActionListener(lsn);
	}
	
	public void addDeleteListener(ActionListener lsn)
	{
		jbtDelete.addActionListener(lsn);
	}
	
	public void addDoneListener(ActionListener lsn)
	{
		jbtDone.addActionListener(lsn);
	}
	
	public void addClearListener(ActionListener lsn)
	{
		jbtClear.addActionListener(lsn);
	}
	
	public void addApproveListener(ActionListener lsn)
	{
		jbtApprove.addActionListener(lsn);
	}
	
	public void addApproveAllListener(ActionListener lsn)
	{
		jbtApproveAll.addActionListener(lsn);
	}
	
	public void addDenyListener(ActionListener lsn)
	{
		jbtDeny.addActionListener(lsn);
	}
	
	public void addDeleteAllListener(ActionListener lsn)
	{
		jbtDeleteAll.addActionListener(lsn);
	}
	
	public void addIgnoreListener(ActionListener lsn)
	{
		jbtIgnore.addActionListener(lsn);
	}
	
	/*public void addHighlightsListener(ActionListener lsn)
	{
		for (int i=0; i<vtHighlights.size(); i++)
		{
			WikiItem wiki = vtHighlights.elementAt(i);
			wiki.addActionListener(lsn);
		}
	}
	
	public void addWikisListener(ActionListener lsn)
	{
		for (int i=0; i<vtWikis.size(); i++)
		{
			WikiItem wiki = vtWikis.elementAt(i);
			wiki.addActionListener(lsn);
		}
	}*/
	
	/****************************************************************************
	* METHODS FOR DEVELOPERS USED ONLY
	****************************************************************************/
	private ArrayList createArrayList()
	{
		int index = 1, author = 123;
		String aut = author+"";
		ArrayList<ArrayList> arr = new ArrayList<ArrayList>();
		ArrayList<String> arrString;
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Tchaikovsky likes guy");
		arrString.add("He just so gay");
		arrString.add(aut);
		arr.add(arrString);
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Mozart doesn't compose with his fingers");
		arrString.add("So hard to play his pieces!");
		arrString.add(aut);
		arr.add(arrString);
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Haydn is Beethoven's teacher");
		arrString.add("");
		arrString.add(aut);
		arr.add(arrString);
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Haydn steals Beethoven's work");
		arrString.add("So Beethoven is very angry");
		arrString.add(aut);
		arr.add(arrString);
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Chopin is from polland");
		arrString.add("He just so gay");
		arrString.add(aut);
		arr.add(arrString);
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Tchaikovsky likes guy");
		arrString.add("And he went to France");
		arrString.add(aut);
		arr.add(arrString);
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Beethoven has a curse on composers who wrote Symphonies");
		arrString.add("The composers died when composing the 8th...");
		arrString.add(aut);
		arr.add(arrString);
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Beethoven is a genius");
		arrString.add("He wrote 9 Symphonies");
		arrString.add(aut);
		arr.add(arrString);
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Schumann's already 200 years old");
		arrString.add("So Clara is 190 years old");
		arrString.add(aut);
		arr.add(arrString);
		
		arrString= new ArrayList<String>();			
		arrString.add(index+++"");
		arrString.add("Schumann's birthday is next Tuesday");
		arrString.add("bila bala");
		arrString.add(aut);
		arr.add(arrString);
		
		return arr;
	}
	
	/*public void refreshAll()
	{
		pnlWelcome.revalidate();
		pnlWelcome.repaint();
		pnlUser.revalidate();
		pnlUser.repaint();
		pnlSearch.revalidate();
		pnlSearch.repaint();
		pnlLinks.revalidate();
		pnlLinks.repaint();
		pnlChat.revalidate();
		pnlChat.repaint();
		pnlChatButton.revalidate();
		pnlChatButton.repaint();
		pnlChatArea.revalidate();
		pnlChatArea.repaint();
		pnlHighlight.revalidate();
		pnlHighlight.repaint();
		pnlWiki.revalidate();
		pnlWiki.repaint();
		pnlFunc.revalidate();
		pnlFunc.repaint();
		
		pnlHeader.revalidate();
		pnlHeader.repaint();
		pnlLeft.revalidate();
		pnlLeft.repaint();
		pnlCenter.revalidate();
		pnlCenter.repaint();
	}*/
}

/*********************************************************/
